import VueRouter from 'vue-router';
import VueCookies from 'vue-cookies'
import tool from "ut/tool";
import Index from 'pa/Index';                           // 首页
import Login from 'pa/Login';                           // 登录
import _Index from 'pain/Index';                        // 网址数据_p
import _User from "pain/User";                          // 个人中心_p
import _AddNotice from "pain/AddNotice";                // 发布公告_p
import _NoticeList from "pain/NoticeList";              // 公告列表_p
import _TopicList from "pain/TopicList";                // 课题列表_p
import _StudentClass from "painad/StudentClass";        // 系部班级_a
import _StudentList from "painad/StudentList";          // 学生列表_a
import _TeacherAdd from "painad/TeacherAdd";            // 注册教师_a
import _TeacherList from "painad/TeacherList";          // 教师列表_a
import _TeacherStation from "painad/TeacherStation";    // 职位管理_a
import _TopicProcess from "painad/TopicProcess";        // 课题审核_a
import _TopicType from "painad/TopicType";              // 课题分类_a
import _MyTopic from "painte/MyTopic";                  // 我的课题_t
import _ReleaseTopic from "painte/ReleaseTopic";        // 发布课题_t
import _StudentOrder from "painte/StudentOrder";        // 学生预约_t
import _StudentWeekly from "painte/StudentWeekly";      // 学生周报_t
import _StudentFile from "painte/StudentFile"           // 学生文件_t
import _dabian from "pain/dabian"                       // 学生答辩-教师端_t
import _dabianShenhe from "pain/dabianShenhe"                    // 学生答辩审核_t

const router = new VueRouter({
    mode: 'history',
    routes: [
        {
            path: '/index',
            component: Index,
			redirect: '/index/index',
            children: [
                { path: 'index',                meta: { title: '首页' },        component: _Index },
                { path: 'user',             meta: { title: '个人中心' },    component: _User },
                { path: 'add_notice',       meta: { title: '发布公告' },    component: _AddNotice },
                { path: 'notice_list',      meta: { title: '公告列表' },    component: _NoticeList },
                { path: 'topic_list',       meta: { title: '课题列表' },    component: _TopicList },
                { path: 'student_class',    meta: { title: '系部班级' },    component: _StudentClass },
                { path: 'student_list',     meta: { title: '学生列表' },    component: _StudentList },
                { path: 'teacher_add',      meta: { title: '注册教师' },    component: _TeacherAdd },
                { path: 'teacher_list',     meta: { title: '教师列表' },    component: _TeacherList },
                { path: 'teacher_station',  meta: { title: '职位管理' },    component: _TeacherStation },
                { path: 'topic_process',    meta: { title: '课题审核' },    component: _TopicProcess },
                { path: 'topic_type',       meta: { title: '课题分类' },    component: _TopicType },
                { path: 'my_topic',         meta: { title: '我的课题' },    component: _MyTopic },
                { path: 'release_topic',    meta: { title: '发布课题' },    component: _ReleaseTopic },
                { path: 'student_order',    meta: { title: '学生预约' },    component: _StudentOrder },
                { path: 'student_weekly',   meta: { title: '学生周报' },    component: _StudentWeekly },
                { path: 'student_file',     meta: { title: '学生文件' },    component: _StudentFile },
                { path: 'dabian',   meta: { title: '答辩' },    component: _dabian },
                { path: 'dabianShenhe',   meta: { title: '答辩审核' },    component: _dabianShenhe },
            ]
        },
        { path: '/login', meta: { title: '登录' }, component: Login, },
        { path: '*', redirect: '/index' }
    ]
})

router.afterEach((to,from) => {
    document.title = to.meta.title;
    if (to.path !== '/login' && !VueCookies.isKey('userInfo')) {
        tool.confirm('提示','登录已过期，请重新登录',_,false).then(res => {
            router.replace('/login');
        })
    }
})

export default router;